import java.util.Arrays;
import java.util.List;
import static java.util.stream.Collectors.toList;
public class TestDishWithStream {

       public static void main(String[] args) {
            List<Dish> menu= Arrays.asList(
                    new Dish("pork",800),
                    new Dish("beef",700),
                    new Dish("chicken",400),
                    new Dish("french fries",530),
                    new Dish("rice",350),
                    new Dish("fruit",120),
                    new Dish("pizza",550));

            List<String> lowCaloriesDishName=menu.stream()
                    .filter(d->d.getCalories()<400)
                    .sorted((d1,d2)->d1.getCalories()-d2.getCalories())
                    .map(d->d.getName())
                    .collect(toList());

            for(String name:lowCaloriesDishName)
                System.out.println(name);
        }
    }


